home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Blogowanie poza sfera / Flock 1.0 beta / flock-1.0RC3.en-US.win32.exe / flock / components / flockPhoto.js < prev    next >
Text File  |  2007-10-18  |  4KB  |  109 lines

  1. //
  2. // BEGIN FLOCK GPL
  3. // 
  4. // Copyright Flock Inc. 2005-2007
  5. // http://flock.com
  6. // 
  7. // This file may be used under the terms of of the
  8. // GNU General Public License Version 2 or later (the "GPL"),
  9. // http://www.gnu.org/licenses/gpl.html
  10. // 
  11. // Software distributed under the License is distributed on an "AS IS" basis,
  12. // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. // for the specific language governing rights and limitations under the
  14. // License.
  15. // 
  16. // END FLOCK GPL
  17. //
  18.  
  19. const FLOCK_PHOTO_CID = Components.ID('{5844743e-41a6-400c-a659-93e0067d1d68}');
  20. const FLOCK_PHOTO_CONTRACTID = '@flock.com/photo;1';
  21. const FLOCK_PHOTO_IID = Components.interfaces.flockIPhoto;
  22.  
  23.  
  24. function flockPhoto() {
  25. }
  26.  
  27. flockPhoto.prototype= {
  28.     id: "",
  29.     thumbnail: "",
  30.     webPageUrl: "",
  31.     midSizePhoto: "",
  32.     largeSizePhoto: "",
  33.     title: "",
  34.     username: "",
  35.     userid: "",
  36.     is_public: "true",
  37.       is_video: "false",
  38.     buildTooltip: function( ) { 
  39.       // do we have to use document from the window to ceate elements? -- ja
  40.       var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  41.                          .getService(Components.interfaces.nsIWindowMediator);
  42.       var win = wm.getMostRecentWindow('navigator:browser');
  43.       if (!win) return;
  44.  
  45.       var lbl = win.document.createElement('label');
  46.       lbl.setAttribute('value', this.title );
  47.       return lbl;
  48.     },
  49.     buildHTML: function( ) {
  50.       return '<a title="'+this.title+'" href="'+this.webPageUrl+'"><img src="'+this.midSizePhoto+'" border="0" /></a>';
  51.     },
  52.     buildBBCode: function ( ) {
  53.       return '[url=' + this.webPageUrl + '][img]'+ this.midSizePhoto +'[/img][/url]';
  54.     },
  55.     buildMiniPage: function ( ) {
  56.       return '<html><head><title>' + this.title +
  57.         ' (' + this.username + ')</title></head><body><center>' +
  58.         this.buildHTML( ) + '</center></body></html>';
  59.     },
  60.     QueryInterface: function(iid) {
  61.         if (!iid.equals(Components.interfaces.nsISupports) &&
  62.             !iid.equals(FLOCK_PHOTO_IID))
  63.             throw Components.results.NS_ERROR_NO_INTERFACE;
  64.         return this;
  65.     }
  66. };
  67.  
  68.  
  69. var flockPhotoModule = {
  70.     registerSelf: function(compMgr, fileSpec, location, type) {
  71.         compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  72.         compMgr.registerFactoryLocation(FLOCK_PHOTO_CID, 
  73.                                         "flockPhoto JS component", 
  74.                                         FLOCK_PHOTO_CONTRACTID, 
  75.                                         fileSpec, 
  76.                                         location,
  77.                                         type);
  78.     },
  79.  
  80.     getClassObject: function(compMgr, cid, iid) {
  81.         if (!cid.equals(FLOCK_PHOTO_CID))
  82.             throw Components.results.NS_ERROR_NO_INTERFACE;
  83.  
  84.         if (!iid.equals(Components.interfaces.nsIFactory))
  85.             throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  86.  
  87.         return flockPhotoFactory;
  88.     },
  89.  
  90.     canUnload: function(compMgr) { return true; }
  91. };
  92.  
  93. var flockPhotoFactory = {
  94.     createInstance: function(outer, iid) {
  95.         if (outer != null)
  96.             throw Components.results.NS_ERROR_NO_AGGREGATION;
  97.     
  98.         if (!iid.equals(FLOCK_PHOTO_IID) &&
  99.             !iid.equals(Components.interfaces.nsISupports))
  100.             throw Components.results.NS_ERROR_INVALID_ARG;
  101.  
  102.         return new flockPhoto();
  103.     }
  104. }
  105.  
  106. /* module initialisation */
  107. function NSGetModule(comMgr, fileSpec) { return flockPhotoModule; }
  108.  
  109.